package l1j.server.server.serverpackets;

import l1j.server.server.model.Instance.L1DollInstance;
import l1j.server.server.model.Instance.L1PcInstance;

// Referenced classes of package l1j.server.server.serverpackets:
// ServerBasePacket , S_DollPack

public class S_DollPack extends ServerBasePacket {

	private static final String S_DOLLPACK = "[S] S_DollPack";
	private byte[] _byte = null;

	public S_DollPack(final L1DollInstance pet, final L1PcInstance pc) {
		/*
		 * int addbyte = 0; int addbyte1 = 1; int addbyte2 = 13; int setting =
		 * 4;
		 */
		this.writeC(S_OPCODE_CHARPACK);
		this.writeH(pet.getX());
		this.writeH(pet.getY());
		this.writeD(pet.getId());
		this.writeH(pet.getGfxId()); // SpriteID in List.spr
		this.writeC(pet.getStatus()); // Modes in List.spr
		this.writeC(pet.getHeading());
		this.writeC(0); // (Bright) - 0~15
		this.writeC(pet.getMoveSpeed()); // ・ケ・ヤ。シ・ノ - 0:normal,1:fast,2:slow
		this.writeD(0);
		this.writeH(0);
		this.writeS(pet.getNameId());
		this.writeS(pet.getTitle());
		this.writeC(0); // ステステエマナラ - 0:mob, item(atk pointer) , 1:poisoned() ,
		// 2:invisable() , 4:pc, 8:cursed() , 16:brave() ,
		// 32:??, 64:??(??) , 128:invisable but name
		this.writeD(0); // ??
		this.writeS(null); // ??
		this.writeS(pet.getMaster() != null ? pet.getMaster().getName() : "");
		this.writeC(0); // ??
		this.writeC(0xFF);
		this.writeC(0);
		this.writeC(pet.getLevel()); // PC = 0, Mon = Lv
		this.writeC(0);
		this.writeC(0xFF);
		this.writeC(0xFF);
	}

	@Override
	public byte[] getContent() {
		if (this._byte == null) {
			this._byte = this._bao.toByteArray();
		}

		return this._byte;
	}

	@Override
	public String getType() {
		return S_DOLLPACK;
	}

}
